import java.util.*;

/**
 * @author LKQ
 * @date 2022/4/1 17:45
 * @description 思路：哈希表存储所有字符，看是否为 2^k个
 */
public class Solution {
    public static void main(String[] args) {

    }
    public boolean hasAllCodes(String s, int k) {
        int n = 1 << k;
        if(s.length() < n +  k - 1) {
            return false;
        }
        Set<String > set = new HashSet<>();
        for(int i = 0; i + k <= s.length(); i++) {
            set.add(s.substring(i, i + k));
        }
        return set.size() == n;
    }
}
